<template>
    <div class="newslist-container">
        <ul class="mui-table-view">
				<li class="mui-table-view-cell mui-media" v-for="item in news" :key="item.id">
					<router-link :to="`/home/newsDetails/` + item.id ">
						<img class="mui-media-object mui-pull-left" :src="item.img_url">
						<div class="mui-media-body">
							<h3>{{item.title}}</h3>
							<p class='mui-ellipsis'>
                                <span>发表时间:{{item.add_time | newsDate}}</span>
                                <span>点击次数: {{item.click}}次</span>
                            </p>
						</div>
					</router-link>
				</li>
			</ul>
    </div>
</template>


<script>
// 导入图文资讯的路径
import {getNewsList} from '@/api/index.js'
// 导入Toast 弹窗 这是js 必须按需导入
import { Toast } from "mint-ui";

	export default ({
		data(){
			return{
				news: []
			}
		},
		methods: {
			getNesList(){
				getNewsList().then(res => {
					console.log(res)
					if(res.data.status === 0) {
						this.news = res.data.message
					}else {
						Toast('获取新闻列表失败')
					}
				})

			}
		},
		created() {
			this.getNesList()
		},
	})
    
</script>

<style lang="scss" scoped>
	.mui-table-view {
		li {
			h3 {
				font-size: 14px;
			}
			.mui-ellipsis {
				font-size: 12px;
				color: #2222dd;
				display: flex;
				justify-content: space-between;
			}
		}
	}
</style>
